﻿using System.Windows.Forms;
namespace ClassMetadataBrowser.ToolControls
{
	public static class Utils
	{
		public const int KeyDownConst = 0x100;

		public static void ChangeRow(this DataGridView gridView, bool up)
		{
			int currentSelectedIndex = 0;
			if (gridView.SelectedRows.Count > 0)
				currentSelectedIndex = gridView.SelectedRows[0].Index;

			int newIndex = 0;

			if (up)
				newIndex = currentSelectedIndex - 1;
			else
				newIndex = currentSelectedIndex + 1;

			gridView.ClearSelection();

			if (newIndex >= 0 && newIndex < gridView.Rows.Count)
			{
				gridView.Rows[newIndex].Selected = true;
				gridView.FirstDisplayedScrollingRowIndex = newIndex;
			}
		}
	}
}
